package com.sun.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface OrderMapper {

    /**
     * 新增订单
     * @param userId 用户id
     * @param OrderName 订单名称
     * @return
     */
    @Insert("insert into order_info(user_id,order_name) value(#{userId},#{OrderName})")
    int insertOrder(@Param("userId")Integer userId,
                    @Param("OrderName")String OrderName);


    /**
     * 根据id列表查询多个订单
     * @param orderIds 订单id列表
     * @return
     */
    @Select({"<script>" +
            "select " +
            " * " +
            " from order_info t" +
            " where t.order_id in " +
            "<foreach collection='orderIds' item='id' open='(' separator=',' close=')'>" +
            " #{id} " +
            "</foreach>"+
            "</script>"})
    List<Map> selectOrderbyIds(@Param("orderIds") List<Long> orderIds);
}
